import React, { useEffect, useState } from 'react'
import {
    Form,
    Slider,
    Button,
    Checkbox,
    Row,
    Col,
    message
  } from 'antd';
  import './index.less'
import { history } from '@/.umi/core/history';
import request from '@/http'

export default function Sijuan() {
    const [xaunze, setxaunze] = React.useState<any[]>();//数据集合
const [pandaun, setpandaun] = React.useState<any[]>();//数据集合
const [tiankong, settiankong] = React.useState<any[]>();//数据集合
const getData=async (values:any)=>{
    await request.get('/api/Examination/Get1?sbjid='+values.checkboxgroup1+'&i='+values.checkboxgroup).then((response:any)=>{
        if(response.code==200){
            // history.push({
            //     pathname:'/student/sijuan',
            //     state:values
            //     })
            console.log(response)
            setxaunze(response.xlist1)
            setpandaun(response.plist1)
            settiankong(response.tlist1)
        }else{
          message.error(response.message)
        }
        })
}

    useEffect(() => {
    // console.log(history.location.state)
    getData(history.location.state)
    
    }, [])
    return (
        <>
        <Row justify='center' className='sjdiv'>
            <Col key={1} span={20} style={{marginTop:10}}><h1 style={{textAlign:'center'}}>专项练习</h1></Col>
            <Col key={2} span={15}>
            <h2>一、选择题</h2>
            <Row justify='center'>
            {xaunze
                ? xaunze.map((item: any, index: any) => {
                    return (
                        <Col span={22} key={index}>
                            <h3><span>{index+1}、</span>{item.title}</h3>
                            <h4>{item.options}</h4>
                            <p>答案：{item.trueAnswer}</p>
                        </Col>
                    );
                    })
                : ''}
            </Row>
            </Col>
            <Col key={3} span={15}>
            <h2>二、判断题</h2>
            <Row justify='center'>
            {pandaun
                ? pandaun.map((item: any, index: any) => {
                    return (
                        <Col span={22} key={index}>
                        <h3><span>{index+1}、</span>{item.title}</h3>
                        <p>答案：{item.trueAnswer}</p>
                    </Col>
                    );
                    })
                : ''}
            </Row>
            </Col>
            <Col key={4} span={15}>
            <h2>三、填空题</h2>
            <Row justify='center'>
            {tiankong
                ? tiankong.map((item: any, index: any) => {
                    return (
                        <Col span={22} key={index}>
                        <h3><span>{index+1}、</span>{item.title}</h3>
                        <p>答案：{item.trueAnswer}</p>
                    </Col>
                    );
                    })
                : ''}
            </Row>
            </Col>
        </Row>
        </>
    )
}
